--- title: "耍杂技的牛" created: 2025-11-28 tags: - 算法 --- # 耍杂技的牛 ## 题目 [耍杂技的牛](https://www.acwing.com/problem/content/127/) ![[image-0e2b76d8.png]] ## 思路分析 能想到体重大的放下面 然后可承受重量大的放下面 但没敢想成是 两个之和更大的放下面…… ## 代码实现 ```cpp #include using namespace std; typedef long long ll; const int N = 50010; struct node{ int w,s; bool operator<(const node& other)const{ return w+s>n; for(int i=0;i>a[i].w>>a[i].s; sort(a,a+n); int res=-1e9; int sum=0; for(int i=0;i